function addEventHandler(target, type, func) {
    if (target.addEventListener) target.addEventListener(type, func, false);
    else if (target.attachEvent) target.attachEvent("on" + type, func);
    else target["on" + type] = func;
}